package routes

import (
	"arabApi/app/api/controllers/CronController"
	"arabApi/app/api/controllers/GitObjController"
	"arabApi/app/api/controllers/loginController"
	"arabApi/app/api/controllers/systemConfigController"
	"arabApi/app/api/controllers/userlimitController"
	"arabApi/app/middlewares"
	"github.com/gin-gonic/gin"
)

func ReginRoute(route *gin.Engine) {

	r := route.Group("/v1")
	r.Use(middlewares.Cors(), middlewares.LogRequest()) //跨域中间件
	{
		// 登录

		r.POST("/login", new(loginController.Login).Login)
		r.Use(middlewares.CheckLogin())
		{

			user := new(userlimitController.User)
			r.GET("/userList", user.List)
			r.GET("/userMsg", user.MSg)
			r.POST("/userEdit", user.Edit)
			r.POST("/userAdd", user.Add)
			r.GET("/userRoleMenu", user.UserRoleMenu)

			role := new(userlimitController.Role)
			r.GET("/roleList", role.List)
			r.GET("/roleMsg", role.MSg)
			r.POST("/roleEdit", role.Edit)
			r.POST("/roleAdd", role.Add)

			userRole := new(userlimitController.UserRole)
			r.POST("/userRoleAdd", userRole.RoleAdd)
			r.GET("/userRole", userRole.UserRole)

			menu := new(userlimitController.Menu)
			r.GET("/menuList", menu.List)
			r.GET("/menuMsg", menu.Msg)
			r.POST("/menuEdit", menu.Edit)
			r.POST("/menuAdd", menu.Add)

			roleMenu := new(userlimitController.RoleMenu)
			r.POST("/RolemenuAdd", roleMenu.RoleAdd)
			r.GET("/menu", roleMenu.Menu)
			r.GET("/Rolemenu", roleMenu.UserRole)

			// 系统配置文件
			systemController := new(systemConfigController.SystemConfig)
			r.GET("/system", systemController.List)
			r.GET("/systemMsg", systemController.SystemMsg)

			r.POST("/sysAdd", systemController.Add)
			//r.POST("sysUpdate",systemController.Update)
			r.POST("/sysUpdate", systemController.Add)
			r.GET("/sysDel", systemController.Del)
			r.GET("/sysState", systemController.State)

			// 定时任务
			Cron := new(CronController.Cron)
			r.GET("/cronList", Cron.List)
			r.GET("/cronMsg", Cron.CronMsg)
			r.POST("/cronEdit", Cron.Edit)

			// git 项目
			GitObj := new(GitObjController.GitObj)
			r.GET("/objList", GitObj.List)
			r.GET("/objMsg", GitObj.MsgById)
			r.POST("/objAdd", GitObj.Add)
			r.POST("/objEdit", GitObj.Edit)

			// git push ptah
			PushPath := new(GitObjController.PushPath)
			r.GET("/pushPathList", PushPath.List)
			r.GET("/pushPathMsg", PushPath.MsgById)
			r.POST("/pushPathAdd", PushPath.Add)
			r.POST("/pushPathEdit", PushPath.Edit)
			r.GET("/pushPathGroup", PushPath.Group)

			gitBranch := new(GitObjController.GitObjBranch)
			r.GET("/objbranchList", gitBranch.List)
			r.GET("/objbranchMsg", gitBranch.MsgById)
			r.POST("/objbranchAdd", gitBranch.Add)
			r.POST("/objbranchEdit", gitBranch.Edit)

			r.GET("/gitnext", new(GitObjController.Exec).Gitnext)
			r.GET("/gitback", new(GitObjController.Exec).Back)
		}

	}

}
